#ifndef __RENDER_MGR_H__
#define __RENDER_MGR_H__

#include "utils/singleton.h"
#include "./renderthread.h"

typedef void (Delegater::*OnRenderStartFunc)();
typedef void (Delegater::*OnBeforeRenderFunc)(float differTime);
typedef void (Delegater::*OnRenderFunc)(float differTime);
typedef void (Delegater::*OnAfterRenderFunc)(float differTime);
typedef void (Delegater::*OnExtRenderFunc)();

class RenderMgr : public Singleton<RenderMgr>
{
public:
	RenderMgr();
	~RenderMgr();

	void SkipOnce();

	//call from main thread
	void Start(HDC hDC);
	void Stop();
	void SetWinSize(Size size);

private:
	//call from render thread
	void OnRenderContextReady();
	void OnRenderScene();
	void OnRenderChangeSize(Size size);

public:
	Event<OnRenderStartFunc> OnStart;
	Event<OnBeforeRenderFunc> OnBeforeRender;
	Event<OnRenderFunc> OnRender;
	Event<OnAfterRenderFunc> OnAfterRender;
	Event<OnExtRenderFunc> OnExtRender;

private:
	RenderThread m_thread;
	time_type m_lastTime;

	//skip once all render event
	bool m_bSkipOnce;
};

#endif